using System;

public class Demo : System.Web.UI.Page {
   protected System.Web.UI.WebControls.DataGrid grid;

   protected override void OnInit(System.EventArgs args) {
      base.OnInit(args);
      Load += new System.EventHandler(Page_Load);
   }

   private void Page_Load(object sender, EventArgs args) {
      System.Collections.ArrayList datasource =
	new System.Collections.ArrayList();
      datasource.Add(new seanfoy.TestDefensiveDatasource.Circle());
      datasource.Add(new seanfoy.TestDefensiveDatasource.Square());
      grid.DataSource = datasource;
      try {
        grid.DataBind();
        throw new ApplicationException("Why do we need DefensiveDatasource?");
      }
      catch (System.Reflection.TargetInvocationException expected) {
        grid.DataSource = new seanfoy.DefensiveDatasource((System.Collections.IEnumerable)grid.DataSource, null);
        grid.DataBind();
      }
   }
}
